import { IToolTipItem } from "../../../../../com/mui/manager/IToolTipItem";
import { ObjCreate } from "../../common/ObjCreate";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ItemData } from "../../../resource/info/ItemData";
import { Language } from "../../../../../extend/language/Language";
import { MountUtil } from "../../../scene/mount/MountUtil";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { SWFPlayer } from "../../../scene/modle/SWFPlayer";
import { ModelType } from "../../../scene/modle/data/ModelType";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
//class MountStartsLogoSp
    
    export  class MountStartsLogoSp /* flash.display.Sprite */ implements IToolTipItem
    {
        constructor()
        {
            
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            this._startsBg = ObjCreate.createBitmap("", 0, 0, this);
            LoaderHelp.addResCallBack(ResFileConst.mountStarts, this.onLoadBmResourceStarts);
            return;
        }

        /* internal  */onLoadBmResourceStarts(): void
        {
            this._loaded = true;
            this._startsBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.MountStartLogoBg);
            return;
        }

        public setMountData(arg1: ItemData): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            this._mountIData = arg1;
            if (!this._mountIData) 
            {
                this.toolTipData = "";
                this.stopEffect();
                return;
            }
            if (this._mountIData.itemExInfo.mount_rein >= 2) 
            {
                if (this._mountIData.itemExInfo.m_haSt != "1") 
                {
                    this.stopEffect();
                    this.toolTipData = Language.getString(70232);
                }
                else 
                {
                    this.playEffect();
                    loc1 = MountUtil.instance.getAllStartsData(this._mountIData.itemExInfo.m_stLv, this._mountIData.itemExInfo.m_stTa);
                    loc2 = HTMLUtil.addColor(Language.getString(70229), GlobalStyle.color9);
                    if (loc1.length == 0) 
                    {
                        loc2 = loc2 + HTMLUtil.addColor("<br>" + Language.getString(70230), GlobalStyle.color9);
                    }
                    loc1.sortOn("key");
                    loc3 = 0;
                    while (loc3 < loc1.length) 
                    {
                        loc2 = loc2 + ("<br>" + HTMLUtil.addColor(loc1[loc3].name + ":", GlobalStyle.color1) + "  " + HTMLUtil.addColor(loc1[loc3].value, GlobalStyle.color2));
                        ++loc3;
                    }
                    this.toolTipData = loc2;
                }
            }
            else 
            {
                this.stopEffect();
                this.toolTipData = Language.getString(70233);
            }
            return;
        }

        /* internal  */playEffect(): void
        {
            if (this._effectPlayer == null) 
            {
                this._effectPlayer = new SWFPlayer();
            }
            this._effectPlayer.load("MountStartsCultureLogoBall.swf", ModelType.NormalSwf, null);
            this._effectPlayer.move(21, 20);
            this._effectPlayer.play();
            if (this.contains(this._effectPlayer) == false) 
            {
                this.addChild(this._effectPlayer);
            }
            return;
        }

        public clean(): void
        {
            this.toolTipData = "";
            this.stopEffect();
            return;
        }

        /* internal  */stopEffect(): void
        {
            if (this._effectPlayer && this.contains(this._effectPlayer)) 
            {
                this._effectPlayer.stop();
                this.removeChild(this._effectPlayer);
            }
            return;
        }

        public get toolTipData()
        {
            return this._tooltipData;
        }

        public set toolTipData(arg1)
        {
            if (arg1 == null || arg1 == "") 
            {
                ToolTipsManager.unregister(this);
            }
            else 
            {
                ToolTipsManager.register(this);
            }
            this._tooltipData = arg1;
            return;
        }

        /* internal */ /* var */_startsBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_effectPlayer: SWFPlayer;

        /* internal */ /* var */_mountIData: ItemData;

        /* internal */ /* var */_loaded: Boolean;

        /* internal */ /* var */_tooltipData;
    }
